package com.quarantine.web;

//import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
//import java.net.URLEncoder;
import java.util.List;

//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.xwork.StringUtils;
import org.apache.struts2.ServletActionContext;
//import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springside.modules.orm.Page;

import com.quarantine.model.fileupload;
import com.quarantine.service.FileUploadManager;
import com.quarantine.web.CrudActionSupport;
@Namespace("/base")
public class FileUploadAction extends CrudActionSupport<fileupload> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private fileupload entity;
	private FileUploadManager fileupload;
	private File pictruepath;
	private String pictruepathFileName;
	private String pictruepathContenttype;
	private String id;
	private String ids;// 逗号隔开id集合
	private List<fileupload> fileList;
	/**
	 * 分頁用
	 */
	private int currentpage;
	private int pageNo;
	public static final int pageSize = 20;
	private int prePage;
	private long totalPages;
	private int nextPage;
	private long allsize;

 
	
	
	@Override
	public fileupload getModel() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String list() throws Exception {
		int pageSize =10;
		Page<fileupload> page = new Page<fileupload>();
		page.setAutoCount(true);
		page.setPageNo(currentpage);
		page.setPageSize(pageSize);
	    fileupload.getList(page);
		setFileList(page.getResult());
		pageNo = page.getPageNo();
		prePage = page.getPrePage();
		nextPage = page.getNextPage();
		totalPages = page.getTotalPages();
		if(totalPages==0){
			
			pageNo=0;
		}
		allsize = page.getTotalCount();
		return "list";
	}

	@Override
	public String input() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}
 

	@Override
	protected void prepareModel() throws Exception {
		if (StringUtils.isEmpty(id)) {
			entity = new fileupload();
		} else {
			entity = fileupload.getById(id);
		}
	}

	public fileupload getEntity() {
		return entity;
	}

	public void setEntity(fileupload entity) {
		this.entity = entity;
	}

	public File getPictruepath() {
		return pictruepath;
	}

	public void setPictruepath(File pictruepath) {
		this.pictruepath = pictruepath;
	}

	public String getPictruepathFileName() {
		return pictruepathFileName;
	}

	public void setPictruepathFileName(String pictruepathFileName) {
		this.pictruepathFileName = pictruepathFileName;
	}

	public String getPictruepathContenttype() {
		return pictruepathContenttype;
	}

	public void setPictruepathContenttype(String pictruepathContenttype) {
		this.pictruepathContenttype = pictruepathContenttype;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getIds() {
		return ids;
	}

	public void setIds(String ids) {
		this.ids = ids;
	}


	public FileUploadManager getFileupload() {
		return fileupload;
	}
    @Autowired
	public void setFileupload(FileUploadManager fileupload) {
		this.fileupload = fileupload;
	}

	public List<fileupload> getFileList() {
		return fileList;
	}

	public void setFileList(List<fileupload> fileList) {
		this.fileList = fileList;
	}

	public int getCurrentpage() {
		return currentpage;
	}

	public void setCurrentpage(int currentpage) {
		this.currentpage = currentpage;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getPrePage() {
		return prePage;
	}

	public void setPrePage(int prePage) {
		this.prePage = prePage;
	}

	public long getTotalPages() {
		return totalPages;
	}

	public void setTotalPages(long totalPages) {
		this.totalPages = totalPages;
	}

	public int getNextPage() {
		return nextPage;
	}

	public void setNextPage(int nextPage) {
		this.nextPage = nextPage;
	}

	public long getAllsize() {
		return allsize;
	}

	public void setAllsize(long allsize) {
		this.allsize = allsize;
	}

	@Override
	public String save() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String delete() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}


}
